#!/bin/bash
echo "检查是否安装docker,docker-compose环境"
docker -v
if [ $? -eq  0 ]; then
 echo "检查到Docker已安装!"
else
 echo "安装docker环境..."
 curl https://gitee.com/ligson/centos7script/raw/master/crux-tools/cruxInstall.sh | bash -s init
fi
if [ ! -d "/data/docker/service/rabbitmq/" ];then
  mkdir -p /data/docker/service/rabbitmq
  else
  echo "/data/docker/service/rabbitmq 文件夹已经存在,请手动确认后删除该目录,载执行创建"
  exit
fi
cd /data/docker/service/rabbitmq
echo "下载mq镜像文件"
wget https://zwfile.yonyougov.tech/share/crux-tools/rabbitmq/rabbitmqImage.tar.gz --no-check-certificate
echo "加载镜像文件"
docker load -i rabbitmqImage.tar.gz
echo "删除镜像文件"
rm -rf rabbitmqImage.tar.gz
echo "下载启动文件"
wget https://zwfile.yonyougov.tech/share/crux-tools/rabbitmq/docker-compose.yml --no-check-certificate
docker network ls | grep mynetwork
if [ $? -eq  0 ]; then
 echo "Docker网络mynetwork已存在!"
else
 echo "创建docker网络"
 docker network create mynetwork
fi
echo "启动 rabbitMq"
docker-compose up -d
